package com.wesh.home.controller;

import com.wesh.home.model.Result;
import com.wesh.home.model.home.BannerDO;
import com.wesh.home.service.HomeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/home")
public class HomeController {

    private final Logger logger = LoggerFactory.getLogger(HomeController.class);

    @Autowired
    HomeService homeService;

    @GetMapping
    public String home(){
        return "welcome to weshishang web";
    }

    @GetMapping("/banner")
    @ResponseBody
    /*@SentinelResource(value = "banner", fallback = "fallback", fallbackClass = FallBackException.class
            , blockHandler = "handlerException", blockHandlerClass = BlockHandlerException.class)*/
    public Result listBanners(){
        //logger.info("get banner...8002");
        List<BannerDO> bannerDOS = homeService.listBanners();
        return Result.success(bannerDOS);
    }

    @GetMapping("/uInfo")
    @ResponseBody
    public String getUserInfo(){
        return homeService.userInfo();
    }

}
